async function getData(res) {
  res.setHeader('content-type', 'text/event-stream');
  for (let i = 0; i < 10; i++) {
    await new Promise(resolve => {
      setTimeout(() => {
        resolve();
      }, 1000)
    });
    res.write(`event: abc\ndata: {"time": "${new Date()}"}\n\n`);
  }
  res.end();
}

module.exports = {
  getData,
};
